<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>1139：[POI2009]Wie</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[POI2009]Wie</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[POI2009]Wie</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                [POI2009]Wie                </h1>
                <p>时间限制：10s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：259MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><p></p>
<div>Byteasar has become a hexer - a conqueror of monsters. Currently he is to return to his hometown Byt</div>
<div>eburg. The way home, alas, leads through a land full of beasts. Fortunately the habitants, forced to</div>
<div>fight the monsters for centuries, have mastered the art of blacksmithery - they are now capable ofma</div>
<div>king special swords that are very efficient against the beasts. The land Byteasar wanders throughis&nbsp;</div>
<div>quite vast: many towns lie there, and many roads connect them. These roads do not cross outside the&nbsp;</div>
<div>towns (mostly because some of them are underground passages).Byteasar has gathered all practicalinfo</div>
<div>rmation about the land (all hexers like to know these things). He knows what kind of monsters hemay&nbsp;</div>
<div>come across each of the roads and how much time he needs to walk it down. He also knows in which vil</div>
<div>lages there are blacksmiths and against what kinds of monsters the swords that they make work.Byteas</div>
<div>ar wants to get back to Byteburg as soon as possible. As a hexer he is quite ashamed that he does no</div>
<div>t know the best route, and that he has no sword on him at the moment. Help him find the shortest pat</div>
<div>h to Byteburg such that whenever he could meet some king of monster, previously he would havea chanc</div>
<div>e to get an appropriate sword to fight the beast. You need not worry about the number or weight of t</div>
<div>he swords - every hexer is as strong as an ox, so he can carry (virtually) unlimited number of equip</div>
<div>ment, swords in particular.</div>
<div>大陆上有n个村庄，m条双向道路，p种怪物，k个铁匠，每个铁匠会居住在一个村庄里，你到了那个村庄后可以让他</div>
<div>给你打造剑，每个铁匠打造的剑都可以对付一些特定种类的怪物，每条道路上都可能出现一些特定种类的怪物，每</div>
<div>条道路都有一个通过所需要的时间，现在要从1走到n，初始的时候你没有剑，要求在经过一条道路的时候，对于任</div>
<div>意一种可能出现在这条道路上的的怪物，你都有已经有至少一把剑可以对付他，求从1走到n的最短时间（打造剑不</div>
<div>需要时间）</div></p><hr/><h3>输入格式</h3><p><div>
<div>第一行正整数 n m p k (1 &le; n &le; 200, 0 &le; m &le; 3 000, 1 &le; p &le; 13, 0 &le; k &le; n). 分别表示点数，边数</div>
<div>，剑/怪物的型号数，铁匠数。&nbsp;</div>
<div>接下来k行描述铁匠，格式如下： 所在点编号w，所能锻造的剑种类数q，升序给出q个1到p的不同的整数表示型号</div>
<div>。 接下来m行描述边： 连接的顶点 x y，通过需要的时间t，路上的怪物数s，s个单调上升的1到p整数表示怪物型</div>
<div>号。</div>
</div></p><hr/><h3>输出格式</h3><p><p>第一行输出最少时间。如果无法到达 输出-1</p></p><hr/><h3>样例输入</h3><pre>6 7 4 2
2 1 2
3 2 1 3
1 2 2 0
2 3 9 0
1 4 2 1 2
2 5 3 0
4 5 5 2 2 3
4 6 18 0
5 6 3 2 1 2</pre><hr/><h3>样例输出</h3><pre>24</pre><hr/><h3>提示</h3><p><p><img alt="" border="0" src="../file/1139_0.jpg" /></p></p><hr/><h3>题目来源</h3><p>没有写明来源</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=1139" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=1139" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>